// 引入vue对象
import Vue from 'vue';
import Vuex from 'vuex';
// 引入vuex

// 让框架使用Vuex,中间件
Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        cityname: localStorage.getItem('cityname') ? localStorage.getItem('cityname') : '北京',
        cityid: localStorage.getItem('cityid') ? localStorage.getItem('cityid') : 100110
    },
    mutations: {
        change_city(state, _city) {
            state.cityname = _city.name
            state.cityid = _city.cityId
            localStorage.setItem('cityname', _city.name)
            localStorage.setItem('cityid', _city.cityId)
        }
    },
    actions: {},
    getters: {},
    modules: {}
})

// 将store导出给main.js使用

export default store